package com.hzeport.bgs22emduty.inbound.api;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.ScreenCheckDTO;
import com.hzeport.bgs22emduty.dto.ScreenCheckDetailVO;
import com.hzeport.bgs22emduty.dto.ScreenDutyMessageDTO;
import com.hzeport.bgs22emduty.dto.screenCheck.ScreenCheckDeleteDTO;
import com.hzeport.bgs22emduty.dto.screenCheck.ScreenCheckDetailShowVO;
import com.hzeport.bgs22emduty.dto.screenCheck.ScreenCheckTopicSaveDTO;
import com.hzeport.bgs22emduty.dto.screenCheck.ScreenCheckUpdateDTO;
import com.hzeport.bgs22emduty.entity.ScreenCheckQuestions;
import com.hzeport.bgs22emduty.entity.ScreenCheckTopic;
import com.hzeport.bgs22emduty.service.ScreenDutyCheckService;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import com.hzeport.bgs22emduty.entity.ScreenCheck;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2023-02-14 09:39:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/screenCheck")
@Api(value = "screenCheck", tags = "值班抽查管理")
@Slf4j
public class ScreenCheckController {

    private final ScreenDutyCheckService screenCheckService;

    @ApiOperation(value = "题目列表", notes = "题目列表")
    @GetMapping("/questionList")
    public BaseResult<List<ScreenCheckTopic>> questionList() {
        List<ScreenCheckTopic> dutyMessageList=screenCheckService.questionList();
        return BaseResult.ok(dutyMessageList);
    }

    @ApiOperation(value = "题目保存", notes = "题目保存")
    @PostMapping("/questionsSave")
    @OperLog( systemName = "ZBCC", description = "TMBC")
    public BaseResult questionsSave(@RequestBody ScreenCheckTopicSaveDTO screenCheckTopicSaveDTO) {
       screenCheckService.questionsSave(screenCheckTopicSaveDTO);
        return BaseResult.ok();
    }


    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/page")
    public BaseResult getScreenCheckPage(@RequestBody ScreenCheckDTO screenCheck) {
        Page<ScreenCheckDetailShowVO>  dutyMessageList=screenCheckService.page(screenCheck);
        return BaseResult.ok(dutyMessageList);
    }


    /**
     * 修改${comments}
     * @param screenCheck ${comments}
     * @return R
     */
    @ApiOperation(value = "修改${comments}", notes = "修改${comments}")
    //@SysLog(.*)
    @PostMapping("updateById")
    @OperLog( systemName = "ZBCC", description = "ZBXG")
    public BaseResult updateById(@RequestBody JSONObject jsonObject) throws Exception {
        return BaseResult.ok(screenCheckService.update(jsonObject));
    }

    /**
     * 修改${comments}
     * @param screenCheck ${comments}
     * @return R
     */
    @ApiOperation(value = "修改${comments}", notes = "修改${comments}")
    //@SysLog(.*)
    @PostMapping("delete")
    @OperLog( systemName = "ZBCC", description = "ZBSC")
    public BaseResult delete(@RequestBody ScreenCheckDeleteDTO screenCheckDeleteDTO) {
        return BaseResult.ok(screenCheckService.delete(screenCheckDeleteDTO));
    }


}
